package timing.ukulele.portal.convertor;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import timing.ukulele.common.data.BaseDataConverter;
import timing.ukulele.data.portal.view.AntMenuVO;
import timing.ukulele.portal.persistent.AntMenu;

@Mapper
public interface MenuConverter extends BaseDataConverter<AntMenu, AntMenuVO> {
    MenuConverter INSTANCE = Mappers.getMapper(MenuConverter.class);

    @Override
    @Mappings({
            @Mapping(target = "badge", ignore = true),
            @Mapping(target = "badgeDot", ignore = true),
            @Mapping(target = "badgeStatus", ignore = true),
            @Mapping(target = "acl", expression = "java(JsonStringListStringConverter.stringToListString(antMenu.getAcl()))"),
    })
    AntMenuVO p2v(AntMenu antMenu);


    @Override
    @Mappings({
            @Mapping(target = "createBy", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateBy", ignore = true),
            @Mapping(target = "updateTime", ignore = true),
            @Mapping(target = "acl", expression = "java(JsonStringListStringConverter.ListStringToString(antMenuVO.getAcl()))")
    })
    AntMenu v2p(AntMenuVO antMenuVO);
}
